from pathlib import Path

from django.db import models
from django.contrib.auth.models import User

app_path = Path(__file__).parent
app_static_path = app_path / 'static'




def user_head_img_path(obj, fileame):

    return f"{app_static_path}/user_{obj.id}/{fileame}"  #绝对路径


class Profile(models.Model):
    objects: models.QuerySet

    user = models.OneToOneField(User, on_delete=models.CASCADE)
    name = models.CharField('昵称', max_length=32)
    head_img = models.FileField("文件字段",upload_to=user_head_img_path)

